﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
    	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    	<link rel="icon" type="image/png" href="img/favicon.png" sizes="16x16">
		<title>阿噹共享汽车-地勤车况系统</title>
		<link rel="stylesheet" href="libs/wuui/weui.min.css" />
		<style type="text/css">
		body, .weui-cell{
			color: #b2b2b2;
			font-size: 13px;
		}
		.page.pg-top{
			padding-top: 50px;
		}
		.page.pg-bottom{
			padding-bottom: 50px;
		}
		header {
			width: 100%;
			height: 50px;
			background: #01ace9;
			position: fixed;
			top: 0;
			z-index: 3;
		}
		header .back:before {
			content: " ";
			display: inline-block;
			height: 10px;
			width: 10px;
			border-width: 0 0 2px 2px;
			border-color: #fff;
			border-style: solid;
			-webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
			transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
		}
		
		header a.placeholder {
			display: block;
			padding: 0 20px
		}
		
		header .placeholder {
			margin: 0;
			height: 50px;
			line-height: 50px;
			background: none;
			font-size:16px;
			color: #fff;
		}
		.weui-cells.uploader{
			margin-top: 0;
		}
		.weui-cells.uploader:before{
			border-top: 0px;
		}
		.uploader .weui-cell:before{
			left: 0;
		}
		.uploader .weui-cell .textarea{
			border: 1px solid #d9d9d9;
			color:#333333;
		}
		.weui-textarea{
			font-size:13px;
		}
		.weui-textarea-counter{
			font-size:12px;
		}
		.weui-cell__bd.textarea input{
			padding:7px;
			border:1px solid #e5e5e5;
			border-radius:4px;
		}
		.weui-cell__bd.textarea input:focus{
			border-color:#d4f2fd;
		}
		/*footer*/
		footer {
		    position: fixed;
		    z-index: 5;
		    bottom: 0;
		    width: 100%;
		    height: 50px;
		    background: #fff;
		    border-top: 1px solid #e5e5e5;
		}
		footer .weui-flex {
		    padding: 7px 5px;
		}
		footer a {
		    text-align: center;
		    line-height: 50px;
		    color: #333;
		}
		footer a {
		    padding: 0 7px;
		}
		footer a div {
		    line-height: 35px;
		    border-radius: 4px;
		    background: #d4f2fd;
		}
		footer a:active div{
			background:#aae2f7;
		}
		.add-lst{
			    border-bottom: 1px solid #e5e5e5;
		}
		a.add-btn,a.del-btn{
		    width: 30%;
		    font-size: 14px;
		    float: left;
		    margin: 15px;
		}
		a.del-btn{
			display: none;
		}
		.weui-cells__title{
		    background: #f2f2f2;
		    margin: 0;
		    padding: 5px 15px;
		}
		.weui-cells.xinshang{
			padding: 0 15px;
		}
		.weui-cells_radio{
			margin-top: 0;
			font-size: 14px;
		}
		.weui-cells_radio:after{
			border: none;
		}
		.weui-cells_radio .weui-cell__bd{
		    display: inline-block;
		    padding: 0 10px 0 15px;
		    width: 50px;
		    color: #333;
		}
		.weui-cells_radio label,.xinshang a{
			display: inline-block;
			width: 85px;
    		padding: 5px 0;
    		margin:10px 10px 10px 0;
		    border: 1px solid #e5e5e5;
		    border-radius: 5px;
		    color: #666;
		    text-align: center;
		}
		.weui-cells_radio .xinshang .new-btn{
			min-width: 85px;
		}
		.oil{
			margin-bottom: 10px;
		}
		.oil label{
			margin:10px 10px 0 0;
		}
		.weui-cells_radio .weui-cell__ft{
			padding: 0;
			text-align: center;
			color: #666;
		}
		.weui-cells_radio .weui-check:checked + .weui-icon-checked:before{
			display: inline-block;
			vertical-align: top;
		}
		.weui-cells_radio .weui-icon-checked{
			vertical-align: inherit;
		}
		.xinshang a.active{
			background: #d4f2fd;
		}
		</style>
	</head>

	<body ontouchstart style="margin-bottom: 60px;">
		
		<header>
			<div class="weui-flex">
				<div><a id="titleCarNum" href="javascript:history.go(-1);" class="placeholder back">  </a></div>
			</div>
		</header>
		
		<form id="checkForm">
			
		<div class="weui-cells__title" style="margin-top: 50px;">基础检查</div>
    	<div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>地点</p>
            </div>
            <div class="weui-cell__bd textarea" style="margin: 10px 10px 10px 0;padding-left: 0;">
    			<input type="text" name="point" />
    	    </div>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>里程数</p>
            </div>
            <div class="weui-cell__bd textarea" style="margin: 10px 10px 10px 0;padding-left: 0;">
    			<input type="text" name="mileage" />
    	    </div>
        </div>
		<div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>轮胎</p>
            </div>
            <label class="weui-cell weui-check__label" for="x11">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c1" id="x11" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x12">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c1" class="weui-check" id="x12" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>外观</p>
            </div>
            <label class="weui-cell weui-check__label" for="x13">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c2" id="x13" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x14">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c2" class="weui-check" id="x14" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>灯光</p>
            </div>
            <label class="weui-cell weui-check__label" for="x15">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c3" id="x15" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x16">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c3" class="weui-check" id="x16" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>喇叭</p>
            </div>
            <label class="weui-cell weui-check__label" for="x17">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c4" id="x17" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x18">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c4" class="weui-check" id="x18" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>雨刮</p>
            </div>
            <label class="weui-cell weui-check__label" for="x19">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c5" id="x19" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x20">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c5" class="weui-check" id="x20" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>内饰</p>
            </div>
            <label class="weui-cell weui-check__label" for="x21">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c6" id="x21" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x22">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c6" class="weui-check" id="x22" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>发动机</p>
            </div>
            <label class="weui-cell weui-check__label" for="x23">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c7" id="x23" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x24">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c7" class="weui-check" id="x24" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>机油</p>
            </div>
            <label class="weui-cell weui-check__label" for="x25">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c8" id="x25" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x26">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c8" class="weui-check" id="x26" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>刹车油</p>
            </div>
            <label class="weui-cell weui-check__label" for="x27">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c9" id="x27" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x28">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c9" class="weui-check" id="x28" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>水箱水</p>
            </div>
            <label class="weui-cell weui-check__label" for="x29">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c10" id="x29" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x30">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c10" class="weui-check" id="x30" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>雨刮水</p>
            </div>
            <label class="weui-cell weui-check__label" for="x31">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c11" id="x31" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x32">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c11" class="weui-check" id="x32" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>

        <div class="weui-cells__title">尾箱</div>
		<div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>备胎</p>
            </div>
            <label class="weui-cell weui-check__label" for="x33">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c12" id="x33" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x34">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c12" class="weui-check" id="x34" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>标贴</p>
            </div>
            <label class="weui-cell weui-check__label" for="x35">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c13" id="x35" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x36">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c13" class="weui-check" id="x36" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>三脚架</p>
            </div>
            <label class="weui-cell weui-check__label" for="x37">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c14" id="x37" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x38">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c14" class="weui-check" id="x38" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>千斤顶</p>
            </div>
            <label class="weui-cell weui-check__label" for="x39">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c15" id="x39" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x40">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c15" class="weui-check" id="x40" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>
        <div class="weui-cells weui-cells_radio">
			<div class="weui-cell__bd">
                    <p>行驶证</p>
            </div>
            <label class="weui-cell weui-check__label" for="x41">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c16" id="x41" checked="checked">
                    <span class="weui-icon-checked">正常</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x42">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c16" class="weui-check" id="x42" >
                    <span class="weui-icon-checked">异常</span>
                </div>
            </label>
        </div>

        <div class="weui-cells__title">是否已加油</div>
		<div class="weui-cells weui-cells_radio xinshang">
            <label class="weui-cell weui-check__label" for="x43">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c17" id="x43" checked="checked">
                    <span class="weui-icon-checked">是</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x44">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c17" class="weui-check" id="x44" >
                    <span class="weui-icon-checked">否</span>
                </div>
            </label>
        </div>

        <div class="weui-cells__title">油量情况</div>
		<div class="weui-cells weui-cells_radio xinshang oil">
            <label class="weui-cell weui-check__label" for="x45">
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" value="1" name="c18" id="x45" checked="checked">
                    <span class="weui-icon-checked">满油</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x46">
                <div class="weui-cell__ft">
                    <input type="radio" value="2" name="c18" class="weui-check" id="x46" >
                    <span class="weui-icon-checked">3/4以上</span>
                </div>
            </label>
            <label class="weui-cell weui-check__label" for="x47">
                <div class="weui-cell__ft">
                    <input type="radio" value="3" name="c18" class="weui-check" id="x47" >
                    <span class="weui-icon-checked">1/2~3/4</span>
                </div>
            </label>
			<label class="weui-cell weui-check__label" for="x48">
                <div class="weui-cell__ft">
                    <input type="radio" value="4" name="c18" class="weui-check" id="x48" >
                    <span class="weui-icon-checked">1/4~1/2</span>
                </div>
            </label>
			<label class="weui-cell weui-check__label" for="x49">
                <div class="weui-cell__ft">
                    <input type="radio" value="5" name="c18" class="weui-check" id="x49" >
                    <span class="weui-icon-checked">1/4以下</span>
                </div>
            </label>
        </div>

       <!--  <div class="weui-cells__title">里程数</div>
		<div class="weui-cells" style="padding: 10px 15px;">
    		<div class="weui-cell__bd textarea">
    			<input type="text" name="mileage" />
    	    </div>
    	</div>
    	
        <div class="weui-cells__title">地点</div>
		<div class="weui-cells" style="padding: 10px 15px;">
    		<div class="weui-cell__bd textarea">
    			<input type="text" name="point" />
    	    </div>
    	</div> -->
    	
    	
        <div class="weui-cells__title">备注</div>
		<div class="weui-cells" style="padding: 10px 15px;">
    		<div class="weui-cell__bd textarea" style="border: 1px solid #e5e5e5">
    	        <textarea name="remarks" class="weui-textarea" placeholder="备注信息..." rows="3"></textarea>
    	        <div class="weui-textarea-counter"><span>0</span>/200</div>
    	    </div>
    	</div>

		<div class="weui-cells__title">车辆有无新伤</div>
		<div class="weui-cells weui-cells_radio xinshang">
			<a id="xs" href="javascript:;'" class="weui-cell weui-check__label new-btn">新伤</a>
			<a id="wx" href="javascript:;" class="weui-cell weui-check__label">无伤</a>
        </div>
        </form>
        <footer>
	    	<div class="weui-flex">
	            <a id="submitCheckForm" href="#" class="weui-flex__item">
	            	<div class="placeholder">提交</div>
	            </a>
	            <a href="javascript:window.location.replace('index.html');" class="weui-flex__item">
	            	<div class="placeholder">取消</div>
	            </a>
	        </div>
	    </footer>

		<script type="text/javascript" src="libs/jquery-2.2.3.min.js" charset="UTF-8"></script>
		<!--weui.js需要在body里面加载才起作用-->
		<script type="text/javascript" src="libs/weui.js/weui.min.js" charset="UTF-8"></script>
		<script type="text/javascript" src="js/app.js" charset="UTF-8"></script>
		<script type="text/javascript">
		(function(){
			var car = app.getJSONSessionStorage('car'),
				user = app.getJSONSessionStorage('user'),
				$titleCarNum = $('#titleCarNum');
			
			$titleCarNum.html(car.carFullNum);
			
			/*新伤无伤点击*/
			$('.xinshang a').on('click', function() {
				$('.xinshang a.active').removeClass('active');
				$(this).addClass('active');
				
				if($(this).hasClass('new-btn')){
					
					//缓存用户选择的车辆表数据
					var cf = getData('#checkForm') ;
					cf['carUserId'] = user.id;
					$.ajax({
		    			url:"/api/tukuan/mobile/car/check/cacheCarCheckChoose",
						type:"post",
						data: cf,
						success: function(result){
							window.location.href="xinshang.html";
						}
					});
					
				}
			})
			
			
			$.ajax({
    			url:"/api/tukuan/mobile/car/check/getUploadXsInfo/"+user.id,
				type:"get",
				success: function(result){
					var xsArray = [] ;
					$.map(result, function(str) {
						var p = JSON.parse(str) ;
						xsArray.push(p) ;
					})
					
					if(undefined != xsArray && xsArray.length > 0) {
						$('#xs').html('新伤(<b style="color:red;">'+xsArray.length+'</b>)').addClass('active');
					} else {
						$('#wx').addClass('active');
					}
					
					$.ajax({
		    			url:"/api/tukuan/mobile/car/check/getCarCheckChoose/"+user.id,
						type:"get",
						success: function(result){
							if(null != result && result != "") {
								$.map(result, function(v, p) {
									var allRadio = $('input[type=radio][name='+p+'][value='+v+']');
									allRadio.prop('checked', true);
								});
								$('textarea[name=remarks]').val(result.remarks);
								
								$('input[name=mileage]').val(result.mileage);
								$('input[name=point]').val(result.point);
							}
						}
					});
				
					$('#submitCheckForm').on('click', function(){
						var m = $('input[name=mileage]').val();
						var p = $('input[name=point]').val();
						if(null == m || "" === m.trim()){
							weui.alert('请填写里程数');
							return ;
						}
                        var re = /^[0-9]+.?[0-9]*$/;
                        if (!re.test(m)) {
                            weui.alert('里程数只能填写数字');
                            return ;
                        }
						if(null == p || "" === p.trim()){
							weui.alert('请填写地点');
							return ;
						}
								
						//是否无伤
						var wx = $('#wx').hasClass('active') ;
						//获取检查项数据
						var cf = getData('#checkForm') ;
						cf['wx']=wx;
						cf['carId']=car.id;
						cf['carUserId']=user.id;
						
						if(undefined != xsArray && xsArray.length > 0 && wx == false) {
							cf['harms'] = xsArray ;
						}
						
						$.ajax({
		        			url:"/api/tukuan/mobile/car/check/insertHandler",
							type:"post",
							data: JSON.stringify(cf),
							contentType: "application/json",
							success: function(result){
								//删除缓存
						       	cleanChooseCache();
							},
							error: function(){
							}
						});
						
					});
					
				},
				error: function(){
				}
			});
			
			//删除缓存
			function cleanChooseCache(){
				$.ajax({
	    			url:"/api/tukuan/mobile/car/check/cleanCarCheckChoose/"+user.id,
					type:"get",
					success: function(result){
						if(result.status) {
				    		window.location.href = 'msg.html?backUrl=index.html&status=1&backTitle='+encodeURI('返回主页') ;
				       	} else {
				       		window.location.href = 'msg.html?status=2&backTitle='+encodeURI('返回')+'&message='+encodeURI('文件上传失败') ;
				       	}
					}
				});
			}
			
			function getData(select, flag) {
				var o = {}, flag = (flag==undefined?true:false);
				$.each($(select).serializeArray(), function(index) {
					if(undefined != flag && flag == true) {
						if (this['value'] != undefined && this['value'].length > 0) {
							if (o[this['name']]) {
								o[this['name']] = o[this['name']] + "," + this['value'];
							} else {
								o[this['name']] = this['value'];
							}
						}
					} else {
						if (o[this['name']]) {
							o[this['name']] = o[this['name']] + "," + this['value'];
						} else {
							o[this['name']] = this['value'];
						}
					}
				});
				return o;
			};
		})();
		</script>
	</body>

</html>